package com.liangzhong.controller
{	
	import com.liangzhong.constants.NotificationConstants;
	import com.liangzhong.manager.DomainManager;
	import com.liangzhong.message.tcp.GameSocket;
	import com.liangzhong.model.AppData;
	import com.liangzhong.proxy.PlayerCenter.PlayerCenterProxy;
	import com.liangzhong.proxy.activity.ActivityProxy;
	import com.liangzhong.proxy.bag.BagProxy;
	import com.liangzhong.proxy.chat.ChatProxy;
	import com.liangzhong.proxy.club.ClubProxy;
	import com.liangzhong.proxy.compete.CompeteProxy;
	import com.liangzhong.proxy.cour.CourtProxy;
	import com.liangzhong.proxy.explore.ExploreProxy;
	import com.liangzhong.proxy.fameHall.FameHallProxy;
	import com.liangzhong.proxy.footballLottery.FootballLotteryProxy;
	import com.liangzhong.proxy.friend.FriendProxy;
	import com.liangzhong.proxy.goldpalace.GoldPalaceProxy;
	import com.liangzhong.proxy.guide.GuideProxy;
	import com.liangzhong.proxy.ladderMatch.LadderMatchProxy;
	import com.liangzhong.proxy.leagueMatch.LeagueMatchProxy;
	import com.liangzhong.proxy.logic.LogicProxy;
	import com.liangzhong.proxy.login.LoginProxy;
	import com.liangzhong.proxy.mail.MailProxy;
	import com.liangzhong.proxy.match.MatchProxy;
	import com.liangzhong.proxy.rankinglist.RankinglistProxy;
	import com.liangzhong.proxy.shop.ShopProxy;
	import com.liangzhong.proxy.talent.TalentProxy;
	import com.liangzhong.proxy.task.TaskProxy;
	import com.liangzhong.proxy.techBar.TechBarProxy;
	import com.liangzhong.proxy.trainingcamp.TrainingcampProxy;
	import com.liangzhong.proxy.winebar.WinebarProxy;
	import com.liangzhong.proxy.youngTrain.YoungTrainProxy;
	import com.liangzhong.view.tips.BaseTips;
	import com.liangzhong.view.tips.CommonTips;
	import com.liangzhong.view.tips.PlayerCardTips;
	import com.liangzhong.view.tips.PlayerCardTipsByPlayer;
	import com.liangzhong.view.tips.TaskTips;
	import com.liangzhong.view.tips.TeamInfoTips;
	import com.socket.clientsocket.ClientSocket;
	import com.socket.clientsocket.SocketState;
	
	import lz.controls.managers.TipsManager;
	
	import org.puremvc.as3.interfaces.ICommand;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;


	/**
	 * 模型初始化
	 * @author lxh
	 * 
	 */	
	public class ModelPrepCommand extends SimpleCommand implements ICommand
	{
		public function ModelPrepCommand()
		{
			super();
		}
		/**
		 *执行处理  
		 * @param notification
		 * 
		 */		
		override public function execute(notification:INotification):void
		{
			var clientSocket :ClientSocket = GameSocket.getInstance().clientSocket;
			GameSocket.getInstance().facade = facade;
			//
			if(clientSocket.connectState == SocketState.SocketState_Connected)
			{
				sendNotification(NotificationConstants.Login_Connect_Server_Success);
				return;
			}
			//初始化
			DomainManager.initilaize();
			var loginProxy :LoginProxy = new LoginProxy();
			//添加login 回调接口
			clientSocket.addClientSocketHandler(loginProxy);
			loginProxy.clientSocket = clientSocket;
			facade.registerProxy(loginProxy);
			//match
			var matchProxy :MatchProxy = new MatchProxy();
			clientSocket.addClientSocketHandler(matchProxy);
			matchProxy.clientSocket = clientSocket;
			facade.registerProxy(matchProxy);
			//logic
			var logicProxy :LogicProxy = new LogicProxy();
			clientSocket.addClientSocketHandler(logicProxy);
			logicProxy.clientSocket = clientSocket;
			facade.registerProxy(logicProxy);
			//背包
			var bagProxy :BagProxy = new BagProxy();
			clientSocket.addClientSocketHandler(bagProxy);
			bagProxy.clientSocket = clientSocket;
			facade.registerProxy(bagProxy);
			//俱乐部
			var clubProxy:ClubProxy = new ClubProxy();
			clientSocket.addClientSocketHandler(clubProxy);
			clubProxy.clientSocket = clientSocket;
			facade.registerProxy(clubProxy);
			//球员中心
			var playercenterProxy:PlayerCenterProxy = new PlayerCenterProxy();
			clientSocket.addClientSocketHandler(playercenterProxy)
			playercenterProxy.clientSocket = clientSocket;
			facade.registerProxy(playercenterProxy);
			//邮件
			var mailProxy :MailProxy = new MailProxy();
			clientSocket.addClientSocketHandler(mailProxy);
			mailProxy.clientSocket = clientSocket;
			facade.registerProxy(mailProxy);
			//酒吧
			var winebarProxy :WinebarProxy = new WinebarProxy();
			clientSocket.addClientSocketHandler(winebarProxy);
			winebarProxy.clientSocket = clientSocket;
			facade.registerProxy(winebarProxy);
			//青训营
			var youngTrainProxy :YoungTrainProxy = new YoungTrainProxy();
			clientSocket.addClientSocketHandler(youngTrainProxy);
			youngTrainProxy.clientSocket = clientSocket;
			facade.registerProxy(youngTrainProxy);
			//科技馆
			var techBarProxy :TechBarProxy = new TechBarProxy();
			clientSocket.addClientSocketHandler(techBarProxy);
			techBarProxy.clientSocket = clientSocket;
			facade.registerProxy(techBarProxy);
			//联赛
			var leagueMatchProxy :LeagueMatchProxy = new LeagueMatchProxy();
			clientSocket.addClientSocketHandler(leagueMatchProxy);
			leagueMatchProxy.clientSocket = clientSocket;
			facade.registerProxy(leagueMatchProxy);
			/*******训练营*******/
			var trainingcampProxy :TrainingcampProxy = new TrainingcampProxy();
			clientSocket.addClientSocketHandler(trainingcampProxy);
			trainingcampProxy.clientSocket = clientSocket;
			facade.registerProxy(trainingcampProxy);
			/*******球场 ***********/
			var courtProxy:CourtProxy = new CourtProxy();
			clientSocket.addClientSocketHandler(courtProxy);
			courtProxy.clientSocket = clientSocket;
			facade.registerProxy(courtProxy);
			/*******聊天 ***********/
			var chatproxy:ChatProxy = new ChatProxy();
			clientSocket.addClientSocketHandler(chatproxy);
			chatproxy.clientSocket = clientSocket;
			facade.registerProxy(chatproxy);
			/*******好友 ***********/
			var fproxy:FriendProxy = new FriendProxy();
			clientSocket.addClientSocketHandler(fproxy);
			fproxy.clientSocket = clientSocket;
			facade.registerProxy(fproxy);
			
			/*******探索 ***********/
			var eproxy:ExploreProxy = new ExploreProxy();
			clientSocket.addClientSocketHandler(eproxy);
			eproxy.clientSocket = clientSocket;
			facade.registerProxy(eproxy);
			
			/*******天梯赛*******/
			var ladderproxy:LadderMatchProxy = new LadderMatchProxy();
			clientSocket.addClientSocketHandler(ladderproxy);
			ladderproxy.clientSocket = clientSocket;
			facade.registerProxy(ladderproxy);
			
			/*******国家对抗赛******/
			var competeproxy:CompeteProxy = new CompeteProxy();
			clientSocket.addClientSocketHandler(competeproxy);
			competeproxy.clientSocket = clientSocket;
			facade.registerProxy(competeproxy);
			
			
			/*******商城******/
			var shopproxy:ShopProxy = new ShopProxy();
			clientSocket.addClientSocketHandler(shopproxy);
			shopproxy.clientSocket = clientSocket;
			facade.registerProxy(shopproxy);
			
			/*******商城******/
			var taskproxy:TaskProxy = new TaskProxy();
			clientSocket.addClientSocketHandler(taskproxy);
			taskproxy.clientSocket = clientSocket;
			facade.registerProxy(taskproxy);
			/*******活动******/
			var activityproxy:ActivityProxy = new ActivityProxy();
			clientSocket.addClientSocketHandler(activityproxy);
			activityproxy.clientSocket = clientSocket;
			facade.registerProxy(activityproxy);
			/*******新手引导******/
			var guideproxy:GuideProxy = new GuideProxy();
			clientSocket.addClientSocketHandler(guideproxy);
			guideproxy.clientSocket = clientSocket;
			facade.registerProxy(guideproxy);
			/*******排行榜******/
			var rankingList:RankinglistProxy = new RankinglistProxy();
			clientSocket.addClientSocketHandler(rankingList);
			rankingList.clientSocket = clientSocket;
			facade.registerProxy(rankingList);
			/*******竞猜******/
			var footballLotteryProxy :FootballLotteryProxy = new FootballLotteryProxy();
			clientSocket.addClientSocketHandler(footballLotteryProxy);
			footballLotteryProxy.clientSocket = clientSocket;
			facade.registerProxy(footballLotteryProxy);
			/*******黄金12宫******/
			var goldPalaceProxy :GoldPalaceProxy = new GoldPalaceProxy();
			clientSocket.addClientSocketHandler(goldPalaceProxy);
			goldPalaceProxy.clientSocket = clientSocket;
			facade.registerProxy(goldPalaceProxy);
			
			
			//荣誉堂
			var fameHallProxy :FameHallProxy = new FameHallProxy();
			clientSocket.addClientSocketHandler(fameHallProxy);
			fameHallProxy.clientSocket = clientSocket;
			facade.registerProxy(fameHallProxy);
			//天赋
			var talentProxy:TalentProxy = new TalentProxy();
			clientSocket.addClientSocketHandler(talentProxy);
			talentProxy.clientSocket = clientSocket;
			facade.registerProxy(talentProxy);
			//connect
			clientSocket.connect(AppData.getInstance().ip,AppData.getInstance().port);
			//TipsManager register
			TipsManager.register(CommonTips);
			TipsManager.register(BaseTips);
			TipsManager.register(PlayerCardTips);
			TipsManager.register(PlayerCardTipsByPlayer);
			TipsManager.register(TeamInfoTips);
			TipsManager.register(TaskTips);
		}
		
	}
}